using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

namespace SunshineFarmWord
{
    public class PlayerFishingBaseState : PlayerBaseStates
    {
        public PlayerFishingBaseState(PlayerStateMachine playerStateMachine) : base(playerStateMachine)
        {
            if(stateMachine.ReusableData.PlayerStatesData.PlayerFishingData == null) stateMachine.ReusableData.PlayerStatesData.PlayerFishingData = new PlayerFishingData();

        }

        #region base function
        public override void Enter()
        {
            base.Enter();
        }

        public override void Exit()
        {
            base.Exit();
        }
        #endregion


        #region 子类初始化数据方法

        // 初始化开始钓鱼状态的参数
        protected virtual void InitCastingReusableData()
        {
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.CurrentState = PlayerFishingData.PlayerFishingStateEnum.CASTING;
        }

        // 初始化等待状态的参数
        protected virtual void InitWaitingReusableData()
        {
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.CurrentState = PlayerFishingData.PlayerFishingStateEnum.WAITING;
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.FishWaitTime = 0;
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.FishWaitTimeMax = playerStatesData.PlayerFishingData.FishWaitTimeMax;
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.FishWaitTimeMin = playerStatesData.PlayerFishingData.FishWaitTimeMin;
        }

        // 初始化钓鱼中收线状态的参数 
        protected virtual void InitReelingReusableData()
        {
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.CurrentState = PlayerFishingData.PlayerFishingStateEnum.REELING;

            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.IsFishCaught = true;
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.CaughtItFish = false;
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.FishReelingCountDown = 0f;
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.FishReelingTime = 0f;
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.FishReelingTimeMax = playerStatesData.PlayerFishingData.FishReelingTimeMax;
        }

        // 初始化结束钓鱼状态的参数
        protected virtual void InitCaughtReusableData()
        {
            stateMachine.ReusableData.PlayerStatesData.PlayerFishingData.CurrentState = PlayerFishingData.PlayerFishingStateEnum.CAUGHT;
        }

        #endregion


        #region 按键事件

        // 按下交互按键
        protected override void OnInteractStarted(InputAction.CallbackContext context)
        {
            base.OnInteractStarted(context);
            // 当前时钓鱼状态 无论任何的子状态 按下交互按键 应该停止钓鱼 TODO
        }
        #endregion

        //
    }
}
